import request from '@/utils/request';

/**
 * 要素信息分页列表查询
 * @param {*} reqWrapperData 
 * @returns 
 */
export function pageList(reqWrapperData) {
    const {query, data} = reqWrapperData
  return request({
    url: '/datastandard/standardDoc/list',
    method: 'post',
    headers: {'X-HTTP-Method-Override': 'GET'},
    params: {
        page:query.page,
        pageSize:query.pageSize
    },
    data:JSON.stringify({
      versionCName:data.versionCName,
    })
  });
}

/**
 * 添加一个新的要素信息
 * @param {*} reqWrapperData 
 * @returns 
 */
export function addOne(reqWrapperData) {
  const {data} = reqWrapperData
  return request({
    url: '/datastandard/standardDoc/add',
    method: 'post',
    data:{
        id:null,
        docName: data.docName,
        filePath:data.filePath,
        docStandardType:data.docStandardType,
        docDesc:data.docDesc
    }
  });
}


/**
 * 修改一个新的要素信息
 * @param {*} reqWrapperData 
 * @returns 
 */
 export function updateOne(reqWrapperData) {
  const {data} = reqWrapperData
  return request({
    url: '/datastandard/standardDoc/update',
    method: 'put',
    data:{
        id:data.id,
        docName: data.docName,
        filePath:data.filePath,
        docStandardType:data.docStandardType,
        docDesc:data.docDesc
    }
  });
}


/**
 * 修改一个要素信息
 * @param {*} reqWrapperData 
 * @returns 
 */
export function deleteOne(reqWrapperData) {
  const {query} = reqWrapperData
  return request({
    url: '/datastandard/standardDoc/delete',
    method: 'delete',
    params:{
      id: query.id
    }
  });
}

/**
 * 上传文档
 * @param {*} reqWrapperData 
 * @returns 
 */
export function uploadStandardDocData(reqFormData){
  return request({
    url: '/datastandard/standardDoc/uploadStandardDocData',
    method:'post',
    data: reqFormData,
    headers: {
      'Content-Type': 'multipart/form-data',
    }
  });
}


/**
 * 根据标准、规范文档id查询关联的要素版本个数
 * @param {*} reqWrapperData 
 * @returns 
 */
export function queryRelationshipExists(reqWrapperData){
  const {query} = reqWrapperData
  return request({
    url: '/datastandard/standardDoc/queryRelationship',
    method: 'get',
    params:{
      standardDocId: query.standardDocId
    }
  });
}